package com.sp.fresh_produce.ex;

public enum ExceptionCodeEnum {

    SUCCESS(1000, "SUCCESS"),
    PARAMS_ERROR(400, "参数错误"),
    NOT_LOGIN(401, "需要登录"),
    FORBIDDEN(403, "没有管理员权限"),
    NOT_FOUND(404, "资源不存在"),
    SYSTEM_ERROR(500, "系统错误"),
    UNKNOWN_ERROR(9999, "未知错误"),
    USER_NOT_EXIST(2001, "用户不存在"),
    USER_EXIST(2000, "用户已存在"),
    NEED_USER_NAME_LENGTH(2000, "用户不能小于2或大于20"),
    INVALID_USER_NAME_FORMAT(2003, "用户名格式错误"),
    NEED_PASSWORD(2005, "需要密码"),
    WRONG_USERNAME_OR_PASSWORD(2006, "用户名或密码错误"),
    NEED_PASSWORD_LENGTH(2004, "密码不能小于3或大于20"),


    // 商品目录分类
    DELETE_CATEGORY_FAILED(3000, "删除商品目录失败"),
    PRODUCT_NAME_EXIST(3001, "该商品已存在"),
    FILE_MKDIR_ERROR(3003, "创建文件夹失败"),
    PRODUCT_ADD_ERROR(3002, "添加商品失败"),
    FILE_UPLOAD_ERROR(3004, "图片上传失败"),
    NEED_USER_NAME(2002, "需要用户名"),
    PRODUCT_UPDATE_ERROR(3005, "修改商品失败"),
    PRODUCT_NOT_EXIST(3006, "商品不存在"),
    PRODUCT_NOT_SALES(3008, "商品不可售"),
    PRODUCT_STOCK_ERROR(3009, "商品库存不足"),
    CART_NOT_EXIST(3010, "购物车不存在"),
    DEL_ERROR(3011, "无法删除"),
    PRODUCT_DELETE_ERROR(3007, "删除商品失败"),

    // 购物车
    CART_EMPTY(3012, "已勾选的购物车商品为空"),
    ORDER_CREATE_ERROR(3013, "创建订单失败"),
    ORDER_NOT_EXIST(3014, "订单不存在"),
    ORDER_STATUS_ERROR(3015, "订单异常"),

    // 订单
    ORDER_PAID(3016, "订单已支付"),
    ORDER_CANCELLED(3017, "订单已取消"),
    ORDER_NOT_PAY_YET(3018, "订单未支付"),
    ORDER_ALREADY_DELIVERED(3019, "订单已发货"),
    ORDER_ALREADY_FINISHED(3020, "订单已完成"),;
    // 错误码
    private final int code;
    // 错误信息
    private final String message;

    /**
     * 枚举构造函数
     *
     * @param code    错误码
     * @param message 错误消息
     */
    ExceptionCodeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
